package cool.webstudy.admin.controller.team.user;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cool.webstudy.admin.model.dto.team.user.CreateTeamUserDTO;
import cool.webstudy.admin.model.dto.team.user.PaginationQueryTeamUserInfoListDTO;
import cool.webstudy.admin.model.dto.team.user.UpdateTeamUserDTO;
import cool.webstudy.admin.model.vo.competition.team.QueryCompTeamDetailWithLoginInfoVO;
import cool.webstudy.admin.model.vo.team.QueryOwnTeamDetailInfoVO;
import cool.webstudy.admin.model.vo.team.user.PaginationQueryTeamUserInfoListVO;
import cool.webstudy.admin.model.vo.team.user.QueryTeamUserDetailInfoVO;
import cool.webstudy.admin.service.TeamUserService;
import cool.webstudy.admin.utils.aspect.request.RequestParameterCheck;
import cool.webstudy.admin.utils.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "队伍与用户关系管理")
@RestController
@RequestMapping("/team-user")
@RequestParameterCheck
public class TeamUserController {
    @Autowired
    TeamUserService teamUserService;

    @GetMapping("/query/detail-info")
    @Operation(summary = "获取队伍与用户关系详细信息接口")
    public Result queryDetailInfo(@RequestParam String unCode) {
        QueryTeamUserDetailInfoVO vo = teamUserService.queryTeamUserDetailInfo(unCode);

        return Result.success(vo);
    }
    @PostMapping("/create")
    @Operation(summary = "创建队伍与用户关系接口")
    public Result create(@RequestBody CreateTeamUserDTO dto){
        teamUserService.createTeamUser(dto);
        return Result.success();
    }
    @PostMapping("/update")
    @Operation(summary = "更新队伍与用户关系接口")
    public Result update(@RequestBody UpdateTeamUserDTO dto){
        teamUserService.updateTeamUser(dto);
        return Result.success();
    }
    @PostMapping("/batch/delete")
    @Operation(summary = "批量删除队伍与用户关系接口")
    public Result batchDelete(@RequestBody List<String> unCodeList) {
        teamUserService.batchDeleteTeamUser(unCodeList);
        return Result.success();
    }
    @PostMapping("/page-query/list")
    @Operation(summary = "分页获取队伍与用户关系信息列表接口")
    public Result<Page<PaginationQueryTeamUserInfoListVO>> paginationQueryTeamUserInfoList(@RequestBody PaginationQueryTeamUserInfoListDTO dto) {
        Page<PaginationQueryTeamUserInfoListVO> vo = teamUserService.paginationQueryTeamUserInfoList(dto);
        return Result.success(vo);
    }
    @GetMapping("/query/own-team/detail-info")
    @Operation(summary = "查询当前登录用户参赛队伍详细信息接口")
    public Result<QueryOwnTeamDetailInfoVO> queryOwnTeamDetailInfo() {
        QueryOwnTeamDetailInfoVO vo = teamUserService.queryOwnTeamDetailInfoVO();
        return Result.success(vo);
    }
}
